<?php

namespace Admin\Model;

use Think\Model;

class ProductStuffModel extends Model {

    protected $trueTableName = 'tb_product_stuff';

    public function getFind($where){
        $result = $this->where($where)->find();
        return $result;
    }
    
    public function getList($where){
        $list = $this->alias('a')
                ->join("left join `tb_dicts` as b on a.dictid=b.id")
                ->where($where)
                ->field('a.dictid as id,a.value as val,b.value as name')
                ->select();
        return $list;
    }
    
    public function saveData($where,$data){
        $result = $this->where($where)->save($data);
        return $result;
    }
    
    public function addData($data){
        $result = $this->add($data);
        return $result;
    }
    
    public function addDataAll($data){
        $result = $this->addAll($data);
        return $result;
    }
    
    public function delData($where){
        $result = $this->where($where)->delete();
        return $result;
    }
    
    public function getListForBudget($where){
        $result = $this->alias('a')
                ->join("left join `tb_dicts` as b on a.dictid=b.id")
                ->where($where)
                ->field("b.value as name,a.value as unit")
                ->select();
        return $result;
    }
}
